

#ifndef UD_DBCURVE_H
#define UD_DBCURVE_H

#include "zdbmain.h"
#include "zgept3dar.h"
#include "zgedblar.h"
#include "zgeplane.h"
#include "zdbptrar.h"

class UcDbSpline;

#pragma pack(push, 8)

class ZSOFT_NO_VTABLE UcDbCurve: public UcDbEntity
{
public:
    UCDB_DECLARE_MEMBERS(UcDbCurve);

    virtual ~UcDbCurve();

    virtual ZSoft::Boolean    isClosed     () const;      
    virtual ZSoft::Boolean    isPeriodic   () const;

    virtual Ucad::ErrorStatus getStartParam(double&) const;
    virtual Ucad::ErrorStatus getEndParam  (double&) const;
    virtual Ucad::ErrorStatus getStartPoint(UcGePoint3d&) const;
    virtual Ucad::ErrorStatus getEndPoint  (UcGePoint3d&) const;

    virtual Ucad::ErrorStatus getPointAtParam(double, UcGePoint3d&) const;
    virtual Ucad::ErrorStatus getParamAtPoint(const UcGePoint3d&, double&)const;
    virtual Ucad::ErrorStatus getDistAtParam (double param, double& dist) const;
    virtual Ucad::ErrorStatus getParamAtDist (double dist, double& param) const;
    virtual Ucad::ErrorStatus getDistAtPoint (const UcGePoint3d&, double&)const;
    virtual Ucad::ErrorStatus getPointAtDist (double, UcGePoint3d&) const;

    virtual Ucad::ErrorStatus getFirstDeriv  (double param,
                                              UcGeVector3d& firstDeriv) const;
    virtual Ucad::ErrorStatus getFirstDeriv  (const UcGePoint3d&,
                                              UcGeVector3d& firstDeriv) const;
    virtual Ucad::ErrorStatus getSecondDeriv (double param,
                                              UcGeVector3d& secDeriv) const;
    virtual Ucad::ErrorStatus getSecondDeriv (const UcGePoint3d&,
                                              UcGeVector3d& secDeriv) const;

    virtual Ucad::ErrorStatus getClosestPointTo(const UcGePoint3d& givenPnt,
                                                UcGePoint3d& pointOnCurve,
                                                ZSoft::Boolean extend
                                                = ZSoft::kFalse) const;
    virtual Ucad::ErrorStatus getClosestPointTo(const UcGePoint3d& givenPnt,
                                                const UcGeVector3d& direction,
                                                UcGePoint3d& pointOnCurve,
                                                ZSoft::Boolean extend
                                                = ZSoft::kFalse) const;

    virtual Ucad::ErrorStatus getOrthoProjectedCurve(const UcGePlane&,
                                                UcDbCurve*& projCrv) const;
    virtual Ucad::ErrorStatus getProjectedCurve(const UcGePlane&,
                                                const UcGeVector3d& projDir,
                                                UcDbCurve*& projCrv) const;

    virtual Ucad::ErrorStatus getOffsetCurves(double offsetDist,
                                          UcDbVoidPtrArray& offsetCurves) const;
    virtual Ucad::ErrorStatus getOffsetCurvesGivenPlaneNormal(
        const UcGeVector3d& normal, double offsetDist,
        UcDbVoidPtrArray& offsetCurves) const;
    virtual Ucad::ErrorStatus getSpline      (UcDbSpline*& spline) const;
    virtual Ucad::ErrorStatus getSplitCurves (const UcGeDoubleArray& params,
                                         UcDbVoidPtrArray& curveSegments) const;
    virtual Ucad::ErrorStatus getSplitCurves (const UcGePoint3dArray& points,
                                         UcDbVoidPtrArray& curveSegments) const;

    virtual Ucad::ErrorStatus extend(double newParam);
    virtual Ucad::ErrorStatus extend(ZSoft::Boolean extendStart,
                                     const UcGePoint3d& toPoint);

    virtual Ucad::ErrorStatus getArea(double&) const;
	virtual Ucad::ErrorStatus reverseCurve();
	UCDB_PORT virtual Ucad::ErrorStatus  getUcGeCurve ( UcGeCurve3d*& pGeCurve, const UcGeTol& tol = UcGeContext::gTol ) const;
	UCDB_PORT virtual Ucad::ErrorStatus  setFromUcGeCurve ( const UcGeCurve3d& geCurve, UcGeVector3d *normal = NULL, const UcGeTol& tol = UcGeContext::gTol );


protected:
    UcDbCurve();
};

#define DBCURVE_METHODS \
virtual ZSoft::Boolean isClosed() const; \
virtual ZSoft::Boolean isPeriodic() const; \
virtual ZSoft::Boolean isPlanar() const; \
virtual Ucad::ErrorStatus getPlane(UcGePlane&, UcDb::Planarity&) const; \
virtual Ucad::ErrorStatus getStartParam(double&) const; \
virtual Ucad::ErrorStatus getEndParam(double&) const; \
virtual Ucad::ErrorStatus getStartPoint(UcGePoint3d&) const; \
virtual Ucad::ErrorStatus getEndPoint(UcGePoint3d&) const; \
virtual Ucad::ErrorStatus getPointAtParam(double, UcGePoint3d&) const; \
virtual Ucad::ErrorStatus getParamAtPoint(const UcGePoint3d&, double&) const; \
virtual Ucad::ErrorStatus getDistAtParam(double, double&) const; \
virtual Ucad::ErrorStatus getParamAtDist(double, double&) const; \
virtual Ucad::ErrorStatus getDistAtPoint(const UcGePoint3d&, double&) const; \
virtual Ucad::ErrorStatus getPointAtDist(double, UcGePoint3d&) const; \
virtual Ucad::ErrorStatus getFirstDeriv(double, UcGeVector3d&) const; \
virtual Ucad::ErrorStatus getFirstDeriv(const UcGePoint3d&,UcGeVector3d&)const;\
virtual Ucad::ErrorStatus getSecondDeriv(double, UcGeVector3d&) const; \
virtual Ucad::ErrorStatus getSecondDeriv(const UcGePoint3d&, \
                              UcGeVector3d&) const; \
virtual Ucad::ErrorStatus getClosestPointTo(const UcGePoint3d&, UcGePoint3d&, \
                              ZSoft::Boolean = ZSoft::kFalse) const; \
virtual Ucad::ErrorStatus getClosestPointTo(const UcGePoint3d&, \
                              const UcGeVector3d&, UcGePoint3d&, \
                              ZSoft::Boolean = ZSoft::kFalse) const; \
virtual Ucad::ErrorStatus getOrthoProjectedCurve(const UcGePlane&, \
                              UcDbCurve*&) const; \
virtual Ucad::ErrorStatus getProjectedCurve(const UcGePlane&, \
                              const UcGeVector3d&, UcDbCurve*&) const; \
virtual Ucad::ErrorStatus getOffsetCurves(double, UcDbVoidPtrArray&) const; \
virtual Ucad::ErrorStatus getSpline(UcDbSpline*&) const; \
virtual Ucad::ErrorStatus getSplitCurves(const UcGeDoubleArray&, \
                              UcDbVoidPtrArray& curveSegments) const; \
virtual Ucad::ErrorStatus getSplitCurves(const UcGePoint3dArray&, \
                              UcDbVoidPtrArray&) const; \
virtual Ucad::ErrorStatus extend(double); \
virtual Ucad::ErrorStatus extend(ZSoft::Boolean, const UcGePoint3d&); \
virtual Ucad::ErrorStatus getArea(double&) const;\
virtual Ucad::ErrorStatus reverseCurve(); \
UCDB_PORT virtual Ucad::ErrorStatus getUcGeCurve ( UcGeCurve3d*& pGeCurve, const UcGeTol& tol = UcGeContext::gTol ) const; \
UCDB_PORT virtual Ucad::ErrorStatus setFromUcGeCurve ( const UcGeCurve3d& geCurve, UcGeVector3d *normal = NULL, const UcGeTol& tol = UcGeContext::gTol );


#pragma pack(pop)

#endif
